/**
 * 给定一个长度为N的数组
 * 选择2个长度为K的连续子段，使得和最大
 * 首先求出前缀和，然后令
 * Li = max(L[i-1], Si - S[i-k])
 * 即不超过i的长度为K的最大子段和
 * 令Ri = max(R[i+1], S[i+k-1]-S[i-1])
 * 即以开始位置在i及其以后的长度为K的最大子段和
 * 然后for每个位置i: ans = max(ans, L[i] + R[i+1])
 */
#include <bits/stdc++.h>
using namespace std;

int getInt(){
    int sgn = 1;
    char ch;
    while(not (isdigit(ch = getchar()) or '-' == ch));
    
    int ret = 0;
    if('-' == ch) sgn = -1;
    else ret = ch ^ '0';
    while(isdigit(ch = getchar())) ret = ret * 10 + (ch ^ '0');
    return sgn == 1 ? ret : -ret;
}

using llt = long long;
llt const INF = 0x1F2F3F4F5F6F7F8F;
llt const NINF = -INF;
int N, K;
vector<llt> A;
vector<llt> S;
vector<llt> L, R;
void proc(){
    N = getInt();
    K = getInt();
    A.assign(N + 1, 0);
    S.assign(N + 1, 0);
    for(int i=1;i<=N;++i)S[i] = S[i - 1] + (A[i] = getInt());
    
    L.assign(N + 1, NINF);
    R.assign(N + 2, NINF);
    
    for(int i=K;i<=N;++i){
        L[i] = max(L[i - 1], S[i] - S[i - K]);
    }
    for(int i=N-K+1;i>0;--i){
        R[i] = max(R[i + 1], S[i + K - 1] - S[i - 1]);
    }
    
    llt ans = NINF;
    for(int i=K;i<=N-K;++i){
        ans = max(ans, L[i] + R[i  + 1]);
    }
    
    cout << ans << "\n";
    return;
}

int main(){
    int nofkase = getInt();
    while(nofkase--) proc();
    return 0;
}